package cn.cocho.android.mc.async;


import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.util.Pair;

/**
 * 异步任务的消息处理（用于异步线程完成任务之后通知主线程并把数据返回给主线程）
 * 
 * @author HAIKANG SONG
 * @time 2013-4-23下午4:06:58
 */
@Deprecated
class AsyncHandler extends Handler{

	@Override
	public void handleMessage(Message msg) {
		try {
			@SuppressWarnings("unchecked")
			Pair<ServiceAsync, Object> pairData = (Pair<ServiceAsync, Object>) msg.obj;
			ServiceAsync task = pairData.first;//获得异步任务对象
			Object data = pairData.second;//获得异步线程中任务执行之后返回的数据
			task.doWork(data);//回调异步接口的实现类
		} catch (Exception e) {
			Log.e(ServiceAsync.class.getName(), "Exception happend when run async task.", e);
		}
	};

}
